[#ftl]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>企业类别</title>
    [#include "/common/commoncss.ftl"/]
    <link rel="stylesheet" type="text/css" href="${base}/plugins/ztree/css/zTreeStyle/zTreeStyle.css" />
    [#include "/common/commonjs.ftl"/]
    <script type="text/javascript" src="${base}/plugins/ztree/js/jquery.ztree.all-3.5.min.js" ></script>
<style type="text/css">
ul.ztree {
    margin-top: 10px;
    border: 1px solid #617775;
    width:240px;
    height:260px;
    overflow-y:scroll;
    overflow-x:auto;
    font-size:15px;
}
</style>
<script type="text/javascript">
var indexmenu=2;
$(function(){
    var setting = {
            view: {
                fontCss : {size:"16px"},
                  selectedMulti: false
            },
            async: {
                enable: true,
                url:"${base}/uyo/platStoreCategory/childDatas",
                autoParam:["id"],
                dataFilter: filter
            },
 /*           check: {
                isSimpleData: true,
                enable: true,
                chkStyle: "radio",
                radioType : "all",
                chkboxType : { "Y" : "", "N" : "" }
            },
  */
            callback: {
                onAsyncSuccess: zTreeOnAsyncSuccess,
                onClick: zTreeOnClick
            }
        };
        
    function zTreeOnClick(event, treeId, treeNode) {
        $("#categoryId").val(treeNode.id);
        $("#categoryCode").val(treeNode.code);
        $("#categoryName").val(treeNode.name);
    };
    function zTreeOnAsyncSuccess(event, treeId, treeNode, msg) {
         var currentNodeId=$("#categoryId").val();
         if(currentNodeId!=null && currentNodeId!=0){    
            var treeObj = $.fn.zTree.getZTreeObj(treeId);
            var node = treeObj.getNodeByParam("id", currentNodeId, null);
            treeObj.selectNode(node);
         }
    };
    function filter(treeId, parentNode, childNodes) {
        if (!childNodes) return null;
        for (var i=0, l=childNodes.length; i<l; i++) {
            childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
        }
        return childNodes;
    } 
    $.fn.zTree.init($("#treedatas"), setting); 
});  
/*弹出提醒框*/
function tips(param){
       var d=dialog({
                content: param,
                icon: 'succeed',
                fixed: true,
                lock: true,
            });
            d.show();
            setTimeout(function () {
                d.close().remove();
            }, 2000);
           return false;
}
function submitForm(){
      var categoryId=$("#categoryId").val();
      var categoryName = $("#categoryName").val();
      var categoryCode = $("#categoryCode").val();
      
      window.parent.categoryId.value=categoryId;    
      window.parent.categoryName.value=categoryName; 
 //     window.parent.categoryCode.value=categoryCode; 

      if(categoryId==null||categoryId==0){
         tips("请选择分类");
      } 
      else{          
         window.parent.d.close().remove();
      }
}
function cancelEdit(){
  window.parent.d.close().remove();
}
</script>
</head>
<body>
  <div class="datatree-div">
      <div>
          <ul id="treedatas"  style="font-size:15px" class="ztree"></ul>
      </div>
  </div> 
<input type="hidden" id="categoryId" name="categoryId" value="${selectedId!0}">
<input type="hidden" id="categoryCode" name="categoryCode">
<input type="hidden" id="categoryName" name="categoryName">
        <div class="pop_btn tc mt20">
            <input type="button" onclick="submitForm()" class="btn_1" value="确定"/>
            <input type="button" onclick="cancelEdit()"class="btn_1" value="取消"/>
        </div>
</body>